//存储cookie到本地
export function setCookie(name: string, value: string) {
    var days = 30;
    const expires = new Date();
    expires.setTime(expires.getTime() + days * 24 * 60 * 60 * 1000);
    document.cookie = `${name}=${value};expires=${expires.toUTCString()};path=/`;
}

//获取cookie
export function getCookie(name: string) {
    var findName = `${name}=`;
    const cookie = document.cookie;
    const cookieArray = cookie.split(';');
    for (let i = 0; i < cookieArray.length; i++) {
        const c = cookieArray[i].trim();
        if (c.indexOf(findName) === 0) {
            return c.substring(name.length + 1, c.length);
        }
    }
    return '';
}

//删除cookie
export function removeCookie(name: string) {
    setCookie(name, '');
}